
import RedPointManager, { RedPointEvent } from "../manager/RedPointManager";


const {ccclass, property} = cc._decorator;

@ccclass
export default class RedPoint extends cc.Component {
    @property
    private eventName: RedPointEvent = RedPointEvent.MissionCount;
    @property(cc.Label)
    private label: cc.Label = null;

    @property(cc.Node)
    private bg: cc.Node = null;
   
    onEnable(){
        RedPointManager.instance.register(this.eventName,this,this.updateNum);
    }
    onDisable(){
        RedPointManager.instance.unregister(this.eventName,this,this.updateNum);
    }
    public updateNum(num:number){
        this.bg.active = Boolean(num);
        if (num) {
            this.label.string = num.toString();
        }
    }
}
